// 随机乱选答案
for (let i = 1; i <=25; i++) {
    let min = 1;  
    let max = 4;  
    let randomIntInRange = Math.floor(Math.random() * (max - min + 1)) + min; 
    let comSelector = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child('+i+') > div.item-question-body > div.question-info > div > div:nth-child('+randomIntInRange+') > div.option-index.can-do';
    let comELE = document.querySelector(comSelector);
    comELE.click()
}

// 提交
document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-header > div > div.function-btn.align-right > button.el-button.el-button--primary.el-button--small.is-round").click()
// document.querySelector("body > div.el-message-box__wrapper > div > div.el-message-box__btns > button.el-button.el-button--default.el-button--small.el-button--primary").click()
// document.querySelector("body > div.el-message-box__wrapper > div > div.el-message-box__btns > button").click()


// 获取答案
var myArray = [];
for (let i = 1; i <= 25; i++) {
    let askSelector = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child('+i+') > div.item-question-body > div.question-info > div.question-answer-exhibition > div > div.check-content > div';
    let askEle = document.querySelector(askSelector);
    if (askEle) {
        // console.log(`${askEle.textContent}`);
        myArray.push(`${askEle.textContent}`)
    } else {
        console.log(`${i} not found.`);
    }
}
console.log(myArray)



// 选择答案
let num;  
for (let i = 0; i < myArray.length; i++) {  
    console.log(myArray[i]);  
    switch (myArray[i]) {  
        case 'A':  
            num = 1;  
            break;  
        case 'B':  
            num = 2;  
            break;  
        case 'C':  
            num = 3;  
            break;  
        case 'D':  
            num = 4;  
            break;  
        default:  
            // 处理其他情况，或者跳过当前循环  
            continue;  
    }  
      
    let comSelector = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child(' + (i + 1) + ') > div.item-question-body > div.question-info > div > div:nth-child(' + num + ') > div.option-index.can-do';  
    let comELE = document.querySelector(comSelector);  
    if (comELE) {  
        comELE.click();  
    } else {  
        console.error('无法找到对应的元素来点击:', comSelector);  
    }  
}
// 提交
document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-header > div > div.function-btn.align-right > button.el-button.el-button--primary.el-button--small.is-round").click()

// 批量播放
for (let i = 1; i <= 50; i++) {
    document.querySelector("#courseSpaceStep4 > div.outline-overview-section-list > div:nth-child('+i+') > div > div.section-addition-statistics-to-study > i").click();
}




// 展开参考答案
for (let i = 1; i <= 25; i++) {
    let askSelector = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child('+i+') > div.item-question-body > div.question-info > div.question-answer-exhibition > div > div.content-title > span.handle-show';
    let askEle = document.querySelector(askSelector);
    if (askEle) {
        askEle.click();
    } else {
        console.log(`${i} not found.`);
    }
}


// 拉取作业
let num;
for (let i = 1; i <= 25; i++) {
    let qes = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child('+i+') > div.item-question-body > div.question-title > div:nth-child(1)';
    let qesEle = document.querySelector(qes);
    let ans = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child('+i+') > div.item-question-body > div.question-info > div.question-answer-exhibition > div > div.check-content > div'
    let ansEle = document.querySelector(ans);

    console.log(qesEle.textContent);
    switch (ansEle.textContent) {
        case 'A':  
            num = 1;  
            break;  
        case 'B':  
            num = 2;  
            break;  
        case 'C':  
            num = 3;  
            break;  
        case 'D':  
            num = 4;  
            break;  
        default:  
            // 处理其他情况，或者跳过当前循环  
            continue;  
    }
    let sec = '#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body > div:nth-child('+i+') > div.item-question-body > div.question-info > div.question-option-list > div:nth-child('+num+') > div.option-content > div:nth-child(1)'
    let secEle = document.querySelector(sec);
    console.log(secEle.textContent)
}
